<template>
  <div class="size-list">
    <!-- 页面头部 -->
    <div class="page-header">
      <h2>尺寸管理</h2>
      <p>管理系统中的所有尺寸信息</p>
    </div>
    
    <div class="content-wrapper">
      <!-- 搜索和操作栏 -->
      <div class="search-action-bar">
        <div class="search-box">
          <input 
            type="text" 
            placeholder="搜索尺寸..." 
            v-model="searchQuery"
            @keyup.enter="searchSizes"
            class="search-input"
          >
          <button class="search-btn" @click="searchSizes">🔍</button>
        </div>
        
        <div class="filter-controls">
          <select v-model="statusFilter" class="filter-select">
            <option value="">全部状态</option>
            <option value="1">启用</option>
            <option value="0">禁用</option>
          </select>
        </div>
        
        <button class="btn btn-primary create-btn" @click="showAddModal">
          <i class="icon">➕</i>
          创建尺寸
        </button>
      </div>
      
      <!-- 加载状态 -->
      <div v-if="loading" class="loading-container">
        <div class="loading-spinner"></div>
        <p>正在加载尺寸数据...</p>
      </div>
      
      <!-- 空状态 -->
      <div v-else-if="filteredSizes.length === 0" class="empty-state">
        <div class="empty-icon">📏</div>
        <h3>暂无尺寸数据</h3>
        <p>{{ searchQuery || statusFilter ? '没有找到匹配的尺寸' : '还没有创建任何尺寸' }}</p>
        <button class="btn btn-primary" @click="showAddModal" v-if="!searchQuery && !statusFilter">
          创建第一个尺寸
        </button>
      </div>
      
      <!-- 尺寸网格 -->
      <div v-else class="sizes-grid">
        <div 
          class="size-card" 
          v-for="size in paginatedSizes" 
          :key="size.sizeId"
          :class="{ inactive: size.status === 0 }"
        >
          <div class="card-content">
            <div class="size-info">
              <h3 class="size-title">{{ size.shoeSize }}码</h3>
              <div class="size-meta">
                <span class="size-id">ID: {{ size.sizeId }}</span>
                <span class="size-status" :class="size.status === 1 ? 'status-active' : 'status-inactive'">
                  {{ size.status === 1 ? '启用' : '禁用' }}
                </span>
              </div>
            </div>
            
            <div class="size-details">
              <div class="detail-row" v-if="size.remarks">
                <span class="label">备注:</span>
                <span class="value">{{ size.remarks }}</span>
              </div>
              <div class="detail-row">
                <span class="label">状态:</span>
                <span class="value" :class="size.status === 1 ? 'status-active' : 'status-inactive'">
                  {{ size.status === 1 ? '启用中' : '已禁用' }}
                </span>
              </div>
            </div>
            
            <div class="card-actions">
              <button class="action-btn edit" @click="editSize(size)" title="编辑">✏️</button>
              <button 
                class="action-btn toggle" 
                @click="toggleSizeStatus(size)" 
                :title="size.status === 1 ? '禁用' : '启用'"
              >
                {{ size.status === 1 ? '⏸️' : '▶️' }}
              </button>
              <button class="action-btn delete" @click="deleteSize(size)" title="删除">🗑️</button>
            </div>
          </div>
        </div>
      </div>

      <!-- 分页组件 -->
      <div v-if="filteredSizes.length > 0" class="pagination-wrapper">
        <div class="pagination-info">
          显示第 {{ (currentPage - 1) * pageSize + 1 }} - 
          {{ Math.min(currentPage * pageSize, filteredSizes.length) }} 条，
          共 {{ filteredSizes.length }} 条记录
        </div>
        
        <div class="pagination-controls">
          <button 
            class="pagination-btn" 
            @click="currentPage = currentPage - 1"
            :disabled="currentPage <= 1"
          >
            上一页
          </button>
          
          <div class="page-numbers">
            <button 
              v-for="page in visiblePages" 
              :key="page"
              class="page-number"
              :class="{ active: page === currentPage }"
              @click="currentPage = page"
            >
              {{ page }}
            </button>
          </div>
          
          <button 
            class="pagination-btn" 
            @click="currentPage = currentPage + 1"
            :disabled="currentPage >= totalPages"
          >
            下一页
          </button>
        </div>
      </div>
    </div>

    <!-- 添加/编辑模态框 -->
    <div class="modal-overlay" v-if="showModal" @click="closeModal">
      <div class="modal-content" @click.stop>
        <div class="modal-header">
          <h3>{{ isEditing ? '编辑尺寸' : '添加尺寸' }}</h3>
          <button class="close-btn" @click="closeModal">×</button>
        </div>
        <div class="modal-body">
          <form @submit.prevent="submitSize">
            <div class="form-group">
              <label for="shoeSize">尺寸大小 *</label>
              <input 
                type="text" 
                id="shoeSize"
                v-model="sizeForm.shoeSize" 
                class="form-input"
                placeholder="请输入尺寸大小，如：40"
                required
              >
            </div>
            
            <div class="form-group">
              <label for="status">状态</label>
              <select id="status" v-model="sizeForm.status" class="form-select">
                <option :value="1">启用</option>
                <option :value="0">禁用</option>
              </select>
            </div>
            
            <div class="form-group">
              <label for="remarks">备注</label>
              <textarea 
                id="remarks"
                v-model="sizeForm.remarks" 
                class="form-textarea"
                placeholder="请输入备注信息"
                rows="3"
              ></textarea>
            </div>
            
            <div class="form-actions">
              <button type="button" class="btn btn-secondary" @click="closeModal">
                取消
              </button>
              <button type="submit" class="btn btn-primary">
                {{ isEditing ? '更新' : '添加' }}
              </button>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'SizeList',
  data() {
    return {
      sizes: [],
      searchQuery: '',
      statusFilter: '',
      currentPage: 1,
      pageSize: 10,
      loading: false,
      showModal: false,
      isEditing: false,
      sizeForm: {
        sizeId: null,
        shoeSize: '',
        status: 1,
        remarks: ''
      }
    };
  },
  computed: {
    filteredSizes() {
      let filtered = this.sizes;
      
      // 搜索过滤
      if (this.searchQuery) {
        filtered = filtered.filter(size => 
          size.shoeSize.toString().includes(this.searchQuery)
        );
      }
      
      // 状态过滤
      if (this.statusFilter !== '') {
        filtered = filtered.filter(size => 
          size.status.toString() === this.statusFilter
        );
      }
      
      return filtered;
    },
    
    paginatedSizes() {
      const start = (this.currentPage - 1) * this.pageSize;
      const end = start + this.pageSize;
      return this.filteredSizes.slice(start, end);
    },
    
    totalPages() {
      return Math.ceil(this.filteredSizes.length / this.pageSize);
    },
    
    visiblePages() {
      const total = this.totalPages;
      const current = this.currentPage;
      const delta = 2;
      
      const range = [];
      const rangeWithDots = [];
      
      for (let i = Math.max(2, current - delta); 
           i <= Math.min(total - 1, current + delta); 
           i++) {
        range.push(i);
      }
      
      if (current - delta > 2) {
        rangeWithDots.push(1, '...');
      } else {
        rangeWithDots.push(1);
      }
      
      rangeWithDots.push(...range);
      
      if (current + delta < total - 1) {
        rangeWithDots.push('...', total);
      } else {
        rangeWithDots.push(total);
      }
      
      return total > 1 ? rangeWithDots : [1];
    }
  },
  mounted() {
    this.loadSizes();
  },
  methods: {
    async loadSizes() {
      this.loading = true;
      try {
        const response = await fetch('http://localhost:8080/api/v1/sizes/list');
        const result = await response.json();
        if (result.ok) {
          this.sizes = result.data || [];
        } else {
          this.showToast(result.message || '加载尺寸失败', 'error');
        }
      } catch (error) {
        console.error('加载尺寸失败:', error);
        this.showToast('加载尺寸失败', 'error');
      } finally {
        this.loading = false;
      }
    },
    
    searchSizes() {
      this.currentPage = 1; // 重置到第一页
    },
    
    showAddModal() {
      this.isEditing = false;
      this.sizeForm = {
        sizeId: null,
        shoeSize: '',
        status: 1,
        remarks: ''
      };
      this.showModal = true;
    },
    
    editSize(size) {
      this.isEditing = true;
      this.sizeForm = {
        sizeId: size.sizeId,
        shoeSize: size.shoeSize,
        status: size.status,
        remarks: size.remarks || ''
      };
      this.showModal = true;
    },
    
    closeModal() {
      this.showModal = false;
      this.isEditing = false;
      this.sizeForm = {
        sizeId: null,
        shoeSize: '',
        status: 1,
        remarks: ''
      };
    },
    
    async submitSize() {
      try {
        if (this.isEditing) {
          await this.updateSize();
        } else {
          await this.addSize();
        }
      } catch (error) {
        console.error('提交尺寸失败:', error);
        this.showToast('操作失败', 'error');
      }
    },
    
    async addSize() {
      try {
        const response = await fetch('http://localhost:8080/api/v1/sizes/add', {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json'
          },
          body: JSON.stringify({
            shoeSize: this.sizeForm.shoeSize,
            status: this.sizeForm.status,
            remarks: this.sizeForm.remarks
          })
        });
        
        const result = await response.json();
        if (result.ok) {
          this.showToast('添加尺寸成功', 'success');
          this.closeModal();
          this.loadSizes();
        } else {
          this.showToast(result.message || '添加尺寸失败', 'error');
        }
      } catch (error) {
        console.error('添加尺寸失败:', error);
        this.showToast('添加尺寸失败', 'error');
      }
    },
    
    async updateSize() {
      try {
        const response = await fetch('http://localhost:8080/api/v1/sizes/update', {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json'
          },
          body: JSON.stringify({
            sizeId: this.sizeForm.sizeId,
            shoeSize: this.sizeForm.shoeSize,
            status: this.sizeForm.status,
            remarks: this.sizeForm.remarks
          })
        });
        
        const result = await response.json();
        if (result.ok) {
          this.showToast('更新尺寸成功', 'success');
          this.closeModal();
          this.loadSizes();
        } else {
          this.showToast(result.message || '更新尺寸失败', 'error');
        }
      } catch (error) {
        console.error('更新尺寸失败:', error);
        this.showToast('更新尺寸失败', 'error');
      }
    },
    
    async toggleSizeStatus(size) {
      try {
        const newStatus = size.status === 1 ? 0 : 1;
        const response = await fetch('http://localhost:8080/api/v1/sizes/update', {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json'
          },
          body: JSON.stringify({
            sizeId: size.sizeId,
            shoeSize: size.shoeSize,
            status: newStatus,
            remarks: size.remarks
          })
        });
        
        const result = await response.json();
        if (result.ok) {
          this.showToast(`${newStatus === 1 ? '启用' : '禁用'}尺寸成功`, 'success');
          this.loadSizes();
        } else {
          this.showToast(result.message || '操作失败', 'error');
        }
      } catch (error) {
        console.error('切换尺寸状态失败:', error);
        this.showToast('操作失败', 'error');
      }
    },
    
    async deleteSize(size) {
      if (confirm(`确定要删除尺寸 "${size.shoeSize}" 吗？`)) {
        try {
          const response = await fetch(`http://localhost:8080/api/v1/sizes/delete/${size.sizeId}`, {
            method: 'POST'
          });
          
          const result = await response.json();
          if (result.ok) {
            this.showToast('删除尺寸成功', 'success');
            this.loadSizes();
          } else {
            this.showToast(result.message || '删除尺寸失败', 'error');
          }
        } catch (error) {
          console.error('删除尺寸失败:', error);
          this.showToast('删除尺寸失败', 'error');
        }
      }
    },
    
    showToast(message, type = 'info') {
      const toast = document.createElement('div');
      toast.className = `toast toast-${type}`;
      toast.textContent = message;
      
      Object.assign(toast.style, {
        position: 'fixed',
        top: '20px',
        right: '20px',
        padding: '12px 20px',
        borderRadius: '6px',
        color: 'white',
        fontSize: '14px',
        fontWeight: '500',
        zIndex: '10000',
        opacity: '0',
        transform: 'translateX(100%)',
        transition: 'all 0.3s ease'
      });

      if (type === 'success') {
        toast.style.background = 'linear-gradient(135deg, #10b981, #059669)';
      } else if (type === 'error') {
        toast.style.background = 'linear-gradient(135deg, #ef4444, #dc2626)';
      } else if (type === 'warning') {
        toast.style.background = 'linear-gradient(135deg, #f59e0b, #d97706)';
      } else {
        toast.style.background = 'linear-gradient(135deg, #3b82f6, #2563eb)';
      }

      document.body.appendChild(toast);

      setTimeout(() => {
        toast.style.opacity = '1';
        toast.style.transform = 'translateX(0)';
      }, 100);

      setTimeout(() => {
        toast.style.opacity = '0';
        toast.style.transform = 'translateX(100%)';
        setTimeout(() => {
          if (document.body.contains(toast)) {
            document.body.removeChild(toast);
          }
        }, 300);
      }, 3000);
    }
  }
};
</script>

<style scoped>
.size-list {
  padding: 0;
}

/* 页面头部样式 */
.page-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 2rem;
  border-radius: 12px;
  margin-bottom: 2rem;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
}

.page-header h2 {
  margin: 0 0 0.5rem 0;
  font-size: 2rem;
  font-weight: 700;
}

.page-header p {
  margin: 0;
  opacity: 0.9;
  font-size: 1.1rem;
}

.content-wrapper {
  background: white;
  border-radius: 12px;
  
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

/* 搜索和操作栏样式 */
.search-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  flex-wrap: wrap;
  gap: 1rem;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 300px;
}

.search-input {
  width: 100%;
  padding: 0.75rem 3rem 0.75rem 1rem;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.875rem;
  transition: all 0.3s ease;
  background: white;
}

.search-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-btn {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-btn:hover {
  transform: translateY(-50%) scale(1.05);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.filter-controls {
  display: flex;
  gap: 1rem;
}

.filter-select {
  padding: 0.75rem 1rem;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.875rem;
  background: white;
  transition: all 0.3s ease;
  min-width: 150px;
}

.filter-select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.create-btn {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.create-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

/* 加载状态样式 */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  color: #6b7280;
}

.loading-spinner {
  width: 3rem;
  height: 3rem;
  border: 3px solid #e5e7eb;
  border-top: 3px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 空状态样式 */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: #6b7280;
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 1rem;
  margin-bottom: 2rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* 尺寸网格样式 */
.sizes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.5rem;
  padding: 1.5rem;
}

.size-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.size-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  border-color: #667eea;
}

.size-card.inactive {
  opacity: 0.7;
}

.size-info {
  margin-bottom: 1rem;
}

.size-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937;
  
  text-overflow: ellipsis;
  white-space: nowrap;
}

.size-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: #6b7280;
}

.size-id {
  font-family: 'Monaco', 'Menlo', monospace;
  font-weight: 600;
}

.size-status {
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-active {
  background: #d1fae5;
  color: #065f46;
}

.status-inactive {
  background: #fee2e2;
  color: #991b1b;
}

.card-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
}

.action-btn {
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
}

.action-btn.edit {
  background: #dbeafe;
  color: #1d4ed8;
}

.action-btn.edit:hover {
  background: #bfdbfe;
  transform: scale(1.1);
}

.action-btn.toggle {
  background: #fef3c7;
  color: #d97706;
}

.action-btn.toggle:hover {
  background: #fde68a;
  transform: scale(1.1);
}

.action-btn.delete {
  background: #fee2e2;
  color: #dc2626;
}

.action-btn.delete:hover {
  background: #fecaca;
  transform: scale(1.1);
}

.card-content {
  padding: 1.5rem;
}

.size-details {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
}

.detail-row .label {
  color: #6b7280;
  font-weight: 500;
}

.detail-row .value {
  color: #1f2937;
  font-weight: 600;
  text-align: right;
  max-width: 60%;
  
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 按钮样式 */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: 2px solid transparent;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: #6c757d;
  color: white;
  border: 2px solid transparent;
}

.btn-secondary:hover {
  background: #5a6268;
  transform: translateY(-1px);
}

.btn .icon {
  margin-right: 8px;
  font-size: 16px;
}

/* 尺寸网格样式 */
.size-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.size-card {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 20px;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  position: relative;
}

.size-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  border-color: #667eea;
}

.size-card.disabled {
  opacity: 0.6;
  background: #e9ecef;
}

.size-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.size-info h3.size-value {
  margin: 0 0 4px 0;
  font-size: 20px;
  color: #2c3e50;
  font-weight: 600;
}

.size-id {
  margin: 0;
  font-size: 12px;
  color: #6c757d;
}

.size-status {
  display: flex;
  align-items: center;
}

.status-badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.status-active {
  background: #d4edda;
  color: #155724;
}

.status-inactive {
  background: #f8d7da;
  color: #721c24;
}

.size-details {
  margin-bottom: 16px;
}

.size-remarks {
  margin: 0 0 8px 0;
  font-size: 14px;
  color: #495057;
  font-style: italic;
}

.size-time {
  margin: 0;
  font-size: 12px;
  color: #6c757d;
}

.size-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-small {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
}

.btn-edit {
  background: #17a2b8;
  color: white;
}

.btn-edit:hover {
  background: #138496;
  transform: translateY(-1px);
}

.btn-delete {
  background: #dc3545;
  color: white;
}

.btn-delete:hover {
  background: #c82333;
  transform: translateY(-1px);
}

.btn-disable {
  background: #ffc107;
  color: #212529;
}

.btn-disable:hover {
  background: #e0a800;
  transform: translateY(-1px);
}

.btn-enable {
  background: #28a745;
  color: white;
}

.btn-enable:hover {
  background: #218838;
  transform: translateY(-1px);
}

/* 分页样式 */
.pagination-wrapper {
  background: #f8fafc;
  padding: 1.5rem;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.pagination-info {
  color: #6b7280;
  font-size: 0.875rem;
  font-weight: 500;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pagination-btn {
  padding: 0.5rem 1rem;
  border: 1px solid #d1d5db;
  background: white;
  color: #374151;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  font-weight: 500;
}

.pagination-btn:hover:not(:disabled) {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #f9fafb;
}

.page-numbers {
  display: flex;
  gap: 0.25rem;
}

.page-number {
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid #d1d5db;
  background: white;
  color: #374151;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-number:hover {
  background: #f3f4f6;
}

.page-number.active {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.page-number.active:hover {
  background: #5a67d8;
  border-color: #5a67d8;
}

/* 模态框样式 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e9ecef;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  color: #2c3e50;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #6c757d;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.close-btn:hover {
  background: #f8f9fa;
  color: #495057;
}

.modal-body {
  padding: 24px;
}

/* 表单样式 */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #2c3e50;
  font-size: 14px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.3s ease;
  box-sizing: border-box;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: #667eea;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e9ecef;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .action-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .action-right {
    justify-content: center;
  }
  
  .search-input {
    width: 100%;
  }
  
  .size-grid {
    grid-template-columns: 1fr;
  }
  
  .pagination {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .page-info {
    order: -1;
    width: 100%;
    text-align: center;
    margin: 0 0 12px 0;
  }
}
</style>